package com.payment.notify.config.task;

import java.util.concurrent.Executor;

import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * 类名：TaskExecutorConfig.java<br>
 * 描述：多线程参数配置<br>
 * 创建者：XINJF<br>
 * 创建日期：2018年4月24日下午1:57:56<br>
 * 版本：1.0<br>
 * 修改者：<br>
 * 修改日期：<br>
 */

@Configuration //声明一个配置文件
@EnableAsync
//@ComponentScan("com.geeboo.notify.*")
public class TaskExecutorConfig implements AsyncConfigurer {
	

	@Bean("threadPool")
	@Override
	public Executor getAsyncExecutor() {
		System.out.println("getAsyncExecutor");
		ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
		//线程池维护线程的最少数量 
		taskExecutor.setCorePoolSize(50);
		//线程池维护线程所允许的空闲时间 
		taskExecutor.setKeepAliveSeconds(30000);
		//线程池维护线程的最大数量
		taskExecutor.setMaxPoolSize(200);
		//线程池所使用的缓冲队列
		taskExecutor.setQueueCapacity(1000);
		taskExecutor.initialize();
		return taskExecutor;
	}

	@Override
	public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
		// TODO Auto-generated method stub
		return null;
	}
	
	

}
